#include "../../Include/Utils/WizUtilsInterface.hpp"

namespace Wiz
{
    namespace Interface
    {
        namespace Object
        {
            Type::~Type()
            {
                ::Wiz::Interface::Set::tForEachIter FE(m_InterfaceSet);
                while (FE)
                {
                    (*FE)->m_ObjectPtr = WIZ_NULLPTR;
                    FE++;
                }
            }

            ::Wiz::Void::Type Type::GetInterface(::Wiz::Interface::Ref IFRef)
            {
                if (IFRef.IsValid())
                {
                    this->PopInterface(&IFRef);
                }
                IFRef.m_ObjectPtr = ::Wiz::Cast::Reinterpret<::Wiz::Void::Ptr>(this);
                this->PushInterface(&IFRef);
            }

            ::Wiz::Void::Type Type::PushInterface(::Wiz::Interface::Ptr IFPtr)
            {
                m_InterfaceSet.Insert(IFPtr);
            }
            ::Wiz::Void::Type Type::PopInterface(::Wiz::Interface::Ptr IFPtr)
            {
                m_InterfaceSet.Remove(IFPtr);
            }
        } /// end of namespace Object

        Type::~Type()
        {
            if (this->IsValid())
            {
                ::Wiz::Interface::Object::Ptr TempPtr = ::Wiz::Cast::Reinterpret<::Wiz::Interface::Object::Ptr>(GetObjectPtr());

                TempPtr->PopInterface(this);
            }
        }
    } /// end of namespace Interface
} /// end of namespace Wiz

